﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>使用DOM实现控件的替换</title>
    <script type="text/javascript">
        function test() {
            var div1 = document.getElementById("divlist1");
            var div2 = document.getElementById("divlist2");
            div1.replaceChild(div2.firstChild, div1.firstChild);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <input  id="btn1" type="button" value="test" onclick="test()"/>
        <div id="divlist1">
            <p>this is test1</p>
        </div>
        <div id="divlist2">
            <p>this is test2</p>
        </div>
    </form>

</body>
</html>